﻿///////////////////////////////////////////////////////////////////////////////
//
// This file is part of the BassDrop project
//   https://code.google.com/p/bass-drop/
//
//
// Creator:	Gergely Krajcsovszki (krajcsovszkig@hotmail.com)
// Date:	2013-08-05 13:15
//
//
// Copyright © 2013-2014. Gergely Krajcsovszki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BassDrop.Core.Common.Options.Items
{
	/// <summary>
	/// OptionsItem for selecting a value from a set of predefined values via combobox or list of radiobuttons.
	/// </summary>
	public class EnumPropertyOptionsItem : PropertyOptionsItem<object>
	{
		/// <summary>
		/// Delegate for getting the displayed text for a specific enum item
		/// </summary>
		/// <param name="value">an enum item to get the text for</param>
		/// <returns>the text to display for the item</returns>
		public delegate string ItemConverterDelegate( object value );

		/// <summary>
		/// Allowed values
		/// </summary>
		public object[] Items // TODO: readonly return, vagy property helyett indexer
		{
			get;
			private set;
		}

		/// <summary>
		/// The delegate to use to get the text to display for the items
		/// </summary>
		public ItemConverterDelegate ItemConverter
		{
			get;
			private set;
		}

		/// <summary>
		/// The way the setting is presented
		/// </summary>
		public EnumPropertyOptionsItemDisplayType PresentationType
		{
			get;
			private set;
		}

		/// <summary>
		/// Creates a new enum property setter options item
		/// </summary>
		/// <param name="setAction">Method called when the property value changed.</param>
		/// <param name="getAction">Method called to read the current value of the property from the plugin.</param>
		/// <param name="items">Allowed values</param>
		/// <param name="itemConverter">the delegate to use to get the text to display for the items</param>
		/// <param name="presentationType">The way the setting is presented</param>
		/// <param name="name">Name/title of the item</param>
		/// <param name="description">The description of the item. Shown typically in tooltips</param>
		public EnumPropertyOptionsItem(
			SetActionDelegate setAction,
			GetActionDelegate getAction,
			object[] items,
			ItemConverterDelegate itemConverter,
			EnumPropertyOptionsItemDisplayType presentationType,
			string name,
			string description )
			: base( setAction, getAction, name, description )
		{
			Items = items;
			ItemConverter = itemConverter;
			PresentationType = presentationType;
		}
	}

	/// <summary>
	/// The way the setting is presented
	/// </summary>
	public enum EnumPropertyOptionsItemDisplayType
	{
		/// <summary>
		/// Select value from a combobox
		/// </summary>
		ComboBox,
		/// <summary>
		/// Pick a radiobutton
		/// </summary>
		RadioButton
	}
}
